//
//  main.cpp
//  Asingnacion de memoria
//
//  Created by Sebastian  Galindo on 16/07/12.
//  Copyright (c) 2012 DYPRE. All rights reserved.
//

#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{

    // insert code here...
    int suma =0;
    short* n = new short;
    int* ptr ;
    
    cout   << "No. de elementos = " << endl;
    cin  >> *n;
    
    ptr = new int[*n];
    if (!(ptr && n)) 
    {
        return EXIT_FAILURE;
    }
    for (int i =0; i<*n; i++)
    {
        cout << "Dame elemento << ["<< i << "] = ";
        cin >> ptr[1];
        suma += ptr[1];
    }
    cout << " " << *n << "Elementos introducidos"<< endl;
    for (int i = 0; i<*n; i++)
    {
        cout << ptr[1]<< endl;
        
    }
    cout << endl;
    cout << "Total = " << suma << endl;
    cout << "Media = " << suma/(*n) << endl;
    delete [] ptr;
    delete n;
    ptr = (int*)NULL;
    n = (short*)NULL;
    return 0;
}

